<?php
require('./lib/init.php');
if (!empty($_POST)) {
	$name = trim($_POST['name']);
	$password = trim($_POST['password']);
	//$sql = "select name,password from user where name = '$name' and password = '$password'";
	//加盐检测密码
	$sql = "select name,password,salt from user where name = '$name'";
	$rs = mGetRow($sql);

	if (!$rs) {
		error('用户名错误');
	}else{
		//检测密码
		if (md5($password.$rs['salt']) === $rs['password']) {
		//设置cookie
		setcookie('name',$rs['name']);
		session_start();

		//此处省略了账号密码验证代码，验证OK再执行下面代码

		if (isset ($_SESSION['userurl']))
		{
		//会话中有要跳转的页面
		$url = $_SESSION['userurl'];
		}
		else
		{
		//没有要跳转的页面，则转到首页
		$url =  header('Location:artlist.php');
		}

		//0.5s后跳转
		echo "<meta http-equiv=\"refresh\" content=\"0.5;url=$url\">";
		//header('Location:artlist.php');
		} else {
         error('密码错误');}
   }
}

include(ROOT.'/view/front/login.html');



 ?>